/**
 * 
 */
package edu.umd.clip.lm.util;

import java.util.Random;

/**
 * @author Denis Filimonov <den@cs.umd.edu>
 *
 */
public final class RandomUtil {

	// Fisher-Yates shuffle algorithm
	public static void shuffleArray(short[] array) {
		shuffleArray(array, new Random());
	}
	
	public static void shuffleArray(short[] array, Random rnd) {
		for(int i=array.length-1; i>1; --i) {
			int j = rnd.nextInt(i);
			short tmp = array[j];
			array[j] = array[i];
			array[i] = tmp;
		}
	}
	
}
